//
//  NetTool.swift
//  手账
//
//  Created by zhuxiaoxiang on 2018/11/15.
//  Copyright © 2018年 zhuxiaoxiang. All rights reserved.
//

import Foundation
import Moya

enum SZModuleAPI {
    case login
    case registe
}

extension SZModuleAPI: TargetType {
    var sampleData: Data {
        return Data()
    }
    
    var baseURL: URL {
        return URL.init(string: "xuxiaodai.com")!
    }
    
    var headers: [String: String]? {
        return ["header": "header"]
    }
    
    var path: String {
        switch self {
        case .login:
            return "xuxiaodai.com"
        case .registe:
            return "xuxiaodai.com"
        }
    }
    
    var method: Moya.Method {
        switch self {
        case .login:
            return .post
        default:
            return .get
        }
    }
    
    var task: Task {
        var params: [String: Any] = [:]
        switch self {
        case .login:
            params = [:]
        case .registe:
            params = ["a":"1"]
        }
        return .requestParameters(parameters: params, encoding: URLEncoding.default)
    }
}
